//http://39.98.155.166:4050/agro_monitor http://192.168.1.110:9090/agro_monitor5 192.168.1.8:8080 http://127.0.0.1:8080/agro_monitor

var basePath = "http://192.168.1.8:8080/agro_monitor";

var basePath2 = "http://testfood.cn:80/agro_monitor/";

var basePath3="http://127.0.0.1:8020/testfood2.0/img/";


function ajaxType(url,type,data1,callback){
	$.ajax({
            url:url,//此处换成你的服务端地址
            type:type,
             xhrFields: { 
    withCredentials: true // 设置运行跨域操作  
 }, 
 data: {"JsonData":JSON.stringify(data1)},
            //jsonpCallback:"fun",//服务器返回执行的方法名
            success:callback,
            error:function (err) {
              alert('500网站后台出错了');
            }
        });
}



function ajaxTypec(url,type,data1,callback){
	$.ajax({
            url:url,//此处换成你的服务端地址
            type:type,
             xhrFields: { 
        withCredentials: true // 设置运行跨域操作  
    }, 
           data: data1,
            success:callback,
            error:function (err) {
              alert('500网站后台出错了');
            }
        });
}


  // 提取相同的对象转为Json
  Array.prototype.sortKeyToJson = function (str) {
    var b = {};
    this.forEach(function (obj) {
      var array = b[obj[str]] || [];
      array.push(obj);
      b[obj[str]] = array;
    });
    return b;
  }
  
  //设置cookie
  function setCookie(cname,cvalue,exdays)
{
  var d = new Date();
  d.setTime(d.getTime()+(exdays*24*60*60*1000));
  var expires = "expires="+d.toGMTString();
  document.cookie = cname + "=" + cvalue + "; " + expires;
}
 //获取cookie
function getCookie(cname)
{
  var name = cname + "=";
  var ca = document.cookie.split(';');
  for(var i=0; i<ca.length; i++) 
  {
    var c = ca[i].trim();
    if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  }
  return "";
}
  
  
function echarts_3(xData,yData,nameData,dataId,colorData) {
        // 基于准备好的dom，初始化echarts实例
        console.log()
        var myChart = echarts.init(document.getElementById(dataId));
        option = {
	tooltip: {
		trigger: 'axis',
		axisPointer: {
			lineStyle: {
				color: '#57617B'
			}
		}
	},
	legend: {
			data: nameData,
		top:'0',
        textStyle: {
            color: "#fff"
        },
        itemGap: 20,
	},
	grid: {
		left: '20',
		right: '20',
		top:'10',
		bottom: '20',
		containLabel: true
	},
	xAxis: [{
		type: 'category',
		boundaryGap: false,
		axisLabel: {
			show: true,
			textStyle: {
                           color: 'rgba(255,255,255,.6)'
                        }
		},
		axisLine: {
			lineStyle: {
				color: 'rgba(255,255,255,.1)'
			}
		},
		data: xData
	}, {
	}],
	yAxis: [{
		axisLabel: {
			show: true,
			textStyle: {
                           color: 'rgba(255,255,255,.6)'
                        }
		},
		axisLine: {
			lineStyle: {
				color: 'rgba(255,255,255,.1)'
			}
		},
		splitLine: {
			lineStyle: {
				color: 'rgba(255,255,255,.1)'
			}
		}
	}],
	series: [{
		name: nameData.toString(),
		type: 'line',
		smooth: true,
		symbol: 'circle',
		symbolSize: 5,
		showSymbol: false,
		lineStyle: {
			normal: {
				width: 2
			}
		},
		areaStyle: {
			normal: {
				color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
					offset: 0,
					color: 'rgba(24, 163, 64, 0.3)'
				}, {
					offset: 0.8,
					color: 'rgba(24, 163, 64, 0)'
				}], false),
				shadowColor: 'rgba(0, 0, 0, 0.1)',
				shadowBlur: 10
			}
		},

		itemStyle: {
			normal: {
				color: colorData,
				borderColor: 'rgba(137,189,2,0.27)',
				borderWidth: 12
			}
		},
		data:yData
	}]
};

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    }

  


